package cn.openea.perpartner.meily.web.entity.dto;

import cn.openea.perpartner.common.core.annotation.Excel;
import cn.openea.perpartner.meily.web.entity.PersonalInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import java.util.function.Function;

/**
 * @author rains
 * @since 2023-07-31 17:44
 */
@Component
public class PersonalInfoDTOFactory {

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    @SuperBuilder
    public static class ExportDTO {

        @Excel(name = "测评师编号")
        private String id;
        @Excel(name = "测评喜好(主)")
        private String mainCategory;
        @Excel(name = "测评喜好(副)")
        private String secondCategory;
        @Excel(name = "兴趣领域")
        private String interests;
        @Excel(name = "抖音平台（有/无）")
        private String tiktok;
        @Excel(name = "抖音粉丝数")
        private String tiktokFans;
        @Excel(name = "抖音获赞数")
        private String tiktokLikes;
        @Excel(name = "小红书平台（有/无）")
        private String littleRedBook;
        @Excel(name = "小红书粉丝数")
        private String littleRedBookFans;
        @Excel(name = "小红书获赞与收藏数")
        private String littleRedBookLikes;
        @Excel(name = "其他社交平台")
        private String otherPlatforms;
        @Excel(name = "平台ID")
        private String userId;
        @Excel(name = "平台昵称")
        private String userName;
        @Excel(name = "关联手机")
        private String phoneNumber;
        @Excel(name = "真实姓名")
        private String realName;
        @Excel(name = "性别")
        private String sex;
        @Excel(name = "年龄层")
        private String ageGroup;
        @Excel(name = "所在地区")
        private String region;
        @Excel(name = "个人身份")
        private String identityJob;
        @Excel(name = "月收入")
        private String monthlyIncome;
        @Excel(name = "测评师等级")
        private String evaluationGrade;
    }

    public Function<PersonalInfo, PersonalInfoDTOFactory.ExportDTO> toExportDTO = (personalInfo) -> {
        if (personalInfo == null) {
            return null;
        }
        PersonalInfoDTOFactory.ExportDTO exportDTO = new PersonalInfoDTOFactory.ExportDTO();
        BeanUtils.copyProperties(personalInfo, exportDTO);
        return exportDTO;
    };
}
